//package com.ng.db.test;
//
//
//import co.elastic.clients.elasticsearch.ElasticsearchClient;
//import co.elastic.clients.elasticsearch.core.BulkResponse;
//import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
//import com.ng.common.utils.PageUtils;
//
//import com.ng.stat.entity.BookEntity;
//
//import com.ng.stat.service.SearchService;
//import org.elasticsearch.action.get.GetRequest;
//import org.elasticsearch.action.get.GetResponse;
//import org.elasticsearch.action.search.SearchRequest;
//import org.elasticsearch.action.search.SearchResponse;
//import org.elasticsearch.client.RequestOptions;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.elasticsearch.search.SearchHits;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author cb
// * @Description TODO
// * @date 2023/3/6
// */
//@SpringBootTest
//public class estest {
//    @Autowired
//    private ElasticsearchClient elasticsearchClient;
//
//    @Autowired
//   private RestHighLevelClient  restHighLevelClient;
//    @Autowired
//    public SearchService searchService;
//    @Test
//    public void testes() throws IOException {
//
//        //var bb=	 searchService.querygroup("publishdate");
//        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>678");
//        List<BulkOperation> bulkOperations = new ArrayList<>();
//        BookEntity entity=new BookEntity();PageUtils page=new PageUtils();
//        page.setPage(1);
//        page.setPageSize(200);
//
//        PageUtils bb= searchService.queryPage(entity,page);
//
////        new BulkOperation.Builder().
////                create(d-> d.document(new Test("zhangsan", "男", 30)).
////                        id("3001").index("newapi")).build();
//
//        for (int i = 0; i <  bb.getList().size(); i++) {
//            int value=i;
//            bulkOperations.add(
//                   new BulkOperation.Builder().create(d->d.document(
//                          bb.getList().get(value)).id(String.valueOf(value)).index("chenbo1")).build()
//
//           );
//            //System.out.println(bb.getList().get(value));
//        }
//
//        BulkResponse response = elasticsearchClient.bulk(e->e.index("chenbo").operations(bulkOperations));
//        //System.out.println(response.took());
//       // System.out.println(response.items());
//
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("zhangsan", "男", 30)).id("3001").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("lisi", "女", 30)).id("3002").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu", "男", 40)).id("3003").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu1", "女", 40)).id("3004").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu2", "男", 50)).id("3005").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu3", "男", 50)).id("3006").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu33", "男", 50)).id("3007").index("newapi")).build());
////        bulkOperations.add(new BulkOperation.Builder().create(d-> d.document(new Test("wangwu333", "男", 50)).id("3008").index("newapi")).build());
//// 使用bulk方法执行批量操作并获得响应
//       // BulkResponse response = elasticsearchClient.bulk(e->e.index("newapi").operations(bulkOperations));
//
//    }
//    @Test
//    public void testbyid() throws IOException
//    {
//        getesbyid("gL-RHIcBxjD6--axovIH");
//    }
//
//    public  Object   getesbyid(String id) throws IOException {
//       // SearchRequest searchRequest = new SearchRequest("join_index",id);
//        GetRequest request = new GetRequest("join_index",id);
//        GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);
//        System.out.println(response.getSourceAsString());// 打印文档内容
//        System.out.println(request);// 返回的全部内容和命令是一样的
//        return   response;
//    }
//
//}
